<?php


namespace app\middleware;


use liliuwei\think\Jump;
use think\facade\Session;

class CheckRule
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure $next
     * @return Response
     */
    protected $checkAdmin = ['test', 'lukunhong'];
    use Jump;
    public function handle($request, \Closure $next)
    {
        $action = $request->action();
        $adminInfo = Session::get('admin');
        if ($adminInfo && in_array($adminInfo['user_name'], $this->checkAdmin)&&$action!='login') {
            if ($request->isPost()) {
               $this->error('测试账号无法修改数据');
            }
        }
        return $next($request);

    }
}